package com.noah.project.controller

import com.noah.project.global.Const
import com.noah.project.model.About
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner

@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class AboutApiControllerTest {
    @Autowired
    lateinit var aboutApiController: AboutApiController

    /*****************日记******************/
    @Test
    @Throws(Exception::class)
    fun addAbout() {
        val about = About(uid = 1044, alias = "lisi", name = "李四", gender = "男", address = "广西桂林", place = "广西")
        val reply = aboutApiController.addAbout(about, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun deleteAbout() {
        val reply = aboutApiController.deleteAbout(1, Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun updateAbout() {
        val about = About(aid = 1065, alias = "lisi", name = "李四", gender = "男", address = "深圳", place = "广西")
        val reply = aboutApiController.updateAbout(about = about, token = Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun getAboutByAlias() {
        val reply = aboutApiController.getAboutByAlias("lisi")
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun getAbout() {
        val reply = aboutApiController.getAbout(aid = 1065, token = Const.TEST_TOKEN)
        println(reply.toString())
    }

    @Test
    @Throws(Exception::class)
    fun getAllNotes() {
        val reply = aboutApiController.getAboutList(uid = 1044, token = Const.TEST_TOKEN)
        println(reply.toString())
    }
}
